package com.et114.modules.suspect.service;
import java.sql.Date;
import java.util.List;

import com.et114.components.simpletable.DataList;
import com.et114.core.utility.DateUtil;
import com.et114.modules.suspect.dao.IMng_SuspectDao;
import com.et114.modules.suspect.vo.SusPectVO;

/**
 * @author zhiweip
 * @version 1.0
 * @created 02-十二月-2010 22:00:30
 */
public class Mng_SuspectServiceImp implements IMng_SuspectService {

	public IMng_SuspectDao m_IMng_SuspectDao;

	public Mng_SuspectServiceImp(){

	}

	public void finalize() throws Throwable {

	}

	public void setM_IMng_SuspectDao ( IMng_SuspectDao mng_SuspectDao ) {
		m_IMng_SuspectDao = mng_SuspectDao;
	}
	public DataList queryDataList(SusPectVO vo) throws Exception{
		return m_IMng_SuspectDao.queryDataList ( vo  );
	}

	/**
	 * 查询投诉跟踪记录
	 */
	public List queryDetailList(SusPectVO vo){
		return m_IMng_SuspectDao.queryDetailList ( vo );
	}

	public Object insertSuspect(SusPectVO vo){
		if(vo.getSpdate ( )==null){
			vo.setSpdate ( DateUtil.getDateOutUSA ( null , false ));
		}
		return m_IMng_SuspectDao.insertSuspect ( vo );
	}

	public int updateSuspect(SusPectVO vo){
		Integer spid=null;
		//System.out.println ("=======getSpid===="+vo.getDealrq ( ));
		if(vo.getSpdate ( )==null){
			vo.setSpdate ( DateUtil.getDateOutUSA ( null , false ));
		}
		if(vo.getSpid ( )==null){
			  spid=new Integer(m_IMng_SuspectDao.insertSuspect ( vo ).toString ( )); 
		}else{
			SusPectVO svo=new SusPectVO();
			spid=vo.getSpid ( );
			svo.setSpid ( vo.getSpid ( ));
			svo.setNextdate ( vo.getNextdate ( ) );
			svo.setSpresult ( vo.getSpresult ( ) );
			svo.setUpdtUser ( vo.getCrtUser ( ) );
			if(svo.getSpresult ( ).equals ( "1" )){
				svo.setDealrq ( vo.getDealrq ( ) );
			}
			m_IMng_SuspectDao.updateSuspect ( svo );
			vo.setRqdate ( vo.getSpdate ( ) );
			vo.setSpid ( spid );
			m_IMng_SuspectDao.insertSuspectDetail ( vo );
		}
		 
		return spid.intValue ( );
	}
	
	public Object loadSuspect(SusPectVO vo){
		return m_IMng_SuspectDao.loadSuspect ( vo );
	}

}